﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FrienDev.BusinessRules;
using FrienDev.Data;

public partial class Controls_Activity_ActivityNavigatorBar : System.Web.UI.UserControl
{
    private int m_activityId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string url = Request.RawUrl;
            if (url.IndexOf("ActivityEdit.aspx") > 0)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["activityId"]))
                {
                    int.TryParse(HttpContext.Current.Request["activityId"], out m_activityId);
                    InitLink();
                }
            }
            else if (string.IsNullOrEmpty(Request.QueryString["activityId"]))
            {
                Response.Redirect("~/home/default.aspx");
            }
            else
            {
                int.TryParse(HttpContext.Current.Request["activityId"], out m_activityId);
                InitLink();
            }
            if (!ActivityRules.Instance.IsCurrentUserIsActivityPromoter(m_activityId))
            {
                li6.Style["display"] = "none";
                li7.Style["display"] = "none";
                li8.Style["display"] = "none";
            }
        }
    }

    private void InitLink()
    {
        hl_Detail.NavigateUrl = "/Activity/detail.aspx?activityid=" + m_activityId;
        hl_Member.NavigateUrl = "/Activity/ActivityMemberList.aspx?activityid=" + m_activityId;
        hl_Invite.NavigateUrl = "/Activity/ActivityInvite.aspx?activityid=" + m_activityId;
        hl_MessageBoard.NavigateUrl = "/Activity/ActivityMessageBoard.aspx?activityid=" + m_activityId;
        hl_Edit.NavigateUrl = "/Activity/ActivityEdit.aspx?activityid=" + m_activityId;
        hl_FeedBackReport.NavigateUrl = "/Activity/ActivityFeedBackReport.aspx?activityid=" + m_activityId;
        hl_Image.NavigateUrl = "/Activity/ImageListDetail.aspx?activityid=" + m_activityId;
        hl_FeedBackTable.NavigateUrl = "/Activity/ActivityFeedBack.aspx?activityid=" + m_activityId;
    }
}
